<?PHP
 
//print_r($_POST);
require_once('../../../../wp-load.php');

require_once('../../../../wp-admin/includes/admin.php');

try
{
global $current_user;
get_currentuserinfo();
//print_r($current_user);

if( !isset($_POST['title']) || !isset($_POST['content']) || !isset($_POST['link']))
	throw new Exception('Some parameter(s) is missing');

$url= parse_url($_POST['link']);

$my_post = array(
	 'post_title' => $_POST['title'],
	 'post_content' => $_POST['content'],
	 'post_status' => 'pending',
	 'post_author' => $current_user->ID,
	 'tags_input' => array("'". isset($url['host']) ? $url['host'] : "Unknown-website" . "'")
);
//print_r($my_post);die;
wp_insert_post( $my_post, $wp_error );
ECHO "Successfully queued and having pending status:   ". $_POST['title'];

}catch(Exception $e)
{
	header('HTTP/1.0 404 Not Found');
	echo "Error:". $e->getMessage();
}	
?>